import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '../src/plugins/element'
import 'animate.css'
import 'element-ui/lib/theme-chalk/index.css'
import PubSub from 'pubsub-js'
import VueClipboard from 'vue-clipboard2'
import JsonExcel from 'vue-json-excel' //引入excel导出插件
import VueContextMenu from 'vue-contextmenu' // 右键点击事件（右键生成菜单）
var dayjs = require('dayjs')
Vue.prototype.dayjs = dayjs // 挂载 dayjs 时间格式方法
Vue.component('downloadExcel', JsonExcel) //excel 导出
Vue.config.productionTip = false
import './App.css' //全局自定义样式
Vue.config.silent = true //隐藏 warn
Vue.use(VueContextMenu)
Vue.use(VueClipboard)
Vue.use(PubSub)
Vue.prototype.$EventBus = new Vue()
import 'echarts-gl'
import { filters } from './plugins/filters.js'

// 定义全局自定义过滤器
Object.keys(filters).forEach((key) => {
    Vue.filter(key, filters[key])
})
//刷新保存状态
if (sessionStorage.getItem('store')) {
    store.replaceState(Object.assign({}, store.state, JSON.parse(sessionStorage.getItem('store'))))
    sessionStorage.removeItem('store')
}
//监听，在页面刷新时将vuex里的信息保存到sessionStorage里
window.addEventListener('beforeunload', () => {
    sessionStorage.setItem('store', JSON.stringify(store.state))
})

new Vue({
    router,
    store,
    render: (h) => h(App),
}).$mount('#app')
